<template>
  <div>
    <table class="bs-table">
       <tr class="bs-table_row">
        <th class="bs-table_th" style="width: 200px">调整建议名称</th>
        <td class="bs-table_td" colspan="3">{{reviseDetailData.reviseName}}</td>
      </tr>
      <tr class="bs-table_row">
        <th class="bs-table_th" style="width: 200px">调整内容</th>
        <td class="bs-table_td" colspan="3">{{reviseDetailData.content}}</td>
      </tr>
      <tr class="bs-table_row">
        <th class="bs-table_th" style="width: 200px">起草单位</th>
        <td class="bs-table_td">{{reviseDetailData.createNickname}}</td>
        <th class="bs-table_th" style="width: 200px">起草时间</th>
        <td class="bs-table_td">{{reviseDetailData.createTime}}</td>
      </tr>
      <tr class="bs-table_row">
        <th class="bs-table_th">相关附件</th>
        <td class="bs-table_td" colspan="3">
          <div v-for="item in reviseDetailData.files" :key="item">
            <el-link :href="'/planning/file/download/'+item.fileId" type="danger"
            >{{item.fileName}}
            </el-link>
          </div>
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
  import {getFileTypeFiles, getFileTypeFile} from '@/views/util'
  import {getReportOpinionDetail} from "@/api/pim/pim";

  export default {
    name: "reviseDetail",
    created() {
      this.getDetailData_revise();
    },
    props: {
      reviseId: null,
    },
    data() {
      return {
        reviseDetailData: {
          reviseName: null,
          content: null,
          createNickname: null,
          createTime: null,
          files: [],
        },
      }
    },
    methods: {
      getDetailData_revise() {
        if (this.reviseId != null && this.reviseId != undefined) {
          getReportOpinionDetail(this.reviseId).then(async response => {
            var records = response.data.data;
            this.reviseDetailData.reviseName = records.reviseName;
            this.reviseDetailData.content = records.content;
            this.reviseDetailData.createNickname = records.createNickname;
            this.reviseDetailData.createTime = this.formatterTime(records.createTime);
            let files = await getFileTypeFiles(records.contentFileIds);
            this.reviseDetailData.files = files;

          })
        }
      },
      formatterTime(time){
        if (time != null) {
          var data = time.split(' ');
          return data[0];
        }
      }
    },
  }
</script>

<style scoped>

</style>
